﻿using System;
using System.Windows;
using System.Windows.Interop;

using SimbaRGVMonitor.Common.Utils;

namespace SimbaRGVMonitor.Common.Linq
{
    public static class WindowExtension
    {
        public static void BringToFront(this Window window)
        {
            var handleInterop = new WindowInteropHelper(window);

            const int showWindow = 0x0040;
            var topMost = new IntPtr(-1);
            var handle = handleInterop.Handle;
            var point = new Point();
            point = window.PointToScreen(point);
            var x = (int)point.X;
            var y = (int)point.Y;
            var width = (int)window.Width;
            var height = (int)window.Height;
            Win32Util.SetWindowPos(handle, topMost, x, y, width, height, showWindow);
        }
    }
}
